package com.justnow.offer;

public class Solution28 {
    public boolean isSymmetric(TreeNode root) {
        if (root == null)
            return true;
        return recur(root.left, root.right);
    }

    private boolean recur(TreeNode root1, TreeNode root2) {
        if (root1 == null && root2 == null) {
            //此时返回true，说明，root1的父节点和root2的父节点不为bull且值相等
            return true;
        }

        if (root1 == null || root2 == null) {
            return false;
        }

        if (root1.val != root2.val) {
            return false;
        }
        return recur(root1.left, root2.right) && recur(root1.right, root2.left);
    }
}

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    public TreeNode(int val) {
        val = val;
    }
}
